package com.yuqiao.read.design.observer3;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SwingObserverDemo {
    JFrame frame;
    public static void main(String[] args) {
        SwingObserverDemo swingObserverDemo = new SwingObserverDemo();
        swingObserverDemo.go();
    }
    public void go(){
        frame = new JFrame();
        JButton button = new JButton("show i do it?");
        button.addActionListener(new AngelListener());
        button.addActionListener(new DevilListener());
        frame.getContentPane().add(BorderLayout.CENTER,button);
    }

    class AngelListener implements ActionListener{

        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("e = [" + e + "]".concat("考虑好"));
        }
    }

    class DevilListener implements ActionListener{

        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("e = [" + e + "]".concat("什么都不用管"));
        }
    }
}
